<?
   if ($this->ad['type'] == 1) {
       $ad_type_txt = 'Give';
   }
   if ($this->ad['type'] == 2) {
       $ad_type_txt = 'Want';
   }
   
?>

<div id="main_list" class="span-24 last main">
    <div class="span-18">
        <div class="section_local_ads">
            <h2><a class="section_ad_link" href="/<?=$this->lang ?>/woeid/<?=$this->ad['woeid_code'].'/'.strtolower($ad_type_txt)?>">
           <?=$this->woeidName.' > '. $this->translate((string)$ad_type_txt) ?></a></h2>
            
            <div class="ad_excerpt_show">
                
            <? if (count ( $this->mensajes ) > 0) {
                        echo '<div class="success"><h2>';
                        foreach ( $this->mensajes as $msg ) {
                            echo $msg . '<br>';
                        }
                        echo '</h2></div>';
                    }
            ?>
          <?php
                      if ($this->ad['photo'] !== null){
                          echo '<div class="ad_list_image">
                            <a title="'.$this->translate('Click to enlarge photo').'" href="/images/uploads/ads/original/'.$this->ad['photo'].'" rel="superbox[image]">
                          <img alt="'.$this->ad['title'].'" src="/images/uploads/ads/100/'.$this->ad['photo'].'" /></a></div>';
                      } else {
                      echo '<div class="ad_list_image">';                 
                      if ($this->lang == 'es') {
                          echo '<img alt="'.$this->ad['title'].'" src="/images/sin_imagen.jpg" /></div>';
                  } else {
                          echo '<img alt="'.$this->ad['title'].'" src="/images/no_image.jpg" /></div>';
                  }
                     }
                  ?>
                  
                  <?php  // if you are the ad owner or admin, then show edit link
                    $auth = Zend_Auth::getInstance ();
                    if ($auth->hasIdentity()):
                             if ( ($this->ad['user_owner'] == $auth->getIdentity()->id)  || ($this->userRole == 1) ): ?>
                                <div class="edit_ad">
                                    <a class="ads_section" href="/<?=$this->lang ?>/ad/edit/id/<?=$this->ad['id'] ?>">    <?=$this->translate('Edit this ad') ?></a>
                        </div><br />
                    <?php endif; endif;?>
          
                  <?php if ($this->ad['type'] == 1): ?>
              <span class="ad_status <?=$this->ad['status'] ?>"><?=$this->translate($this->ad['status']) ?></span>
              <?php endif;?>
          
              <div class="ad_excerpt_title"><div class="ad_title"><h1><?=$this->ad['title'] ?></h1></div></div>
              
              <span class="ad_date"><?=$this->translate('Posted on '). $this->ad['date_created'] ?>
                      <?=$this->translate('by user ') ?>
                    <a class="ads_section" href="/<?=$this->lang ?>/ad/listuser/id/<?=$this->ad['user_owner'] ?>"><?=$this->ad['username'] ?></a>
                  </span>
                                                            
                  <div class="ad_body"><p><?php echo $this->escapeEmail( $this->escape($this->ad['body']) ) ?></p></div>
                
                    <div class="ad_meta_info">  
                     <div class="readings_count"><?=$this->countReadedAd['counter'] . ' ' .$this->translate('readings') ?></div>
                
                     <?php if ($this->checkCountAd): ?>
                             <div class="comments_count"><?=', '.$this->escape( $this->checkCountAd == null  ? 0 : $this->checkCountAd ).' '.$this->translate('comments') ?></div>
                      <?php endif;?>
              </div>
                
          <div class="sharelinks"><?=$this->translate('Share this ad:').'  ';?>
                    <table class="tablapostfooter" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td>
                                               <!-- facebook -->
                                                    <fb:like expr:href="http://segundamanita.com/<?=$this->lang;?>/ad/show/id/<?=$this->ad['id'].'/'.$this->escape($this->ad['title'])?>" send="false" layout="button_count" show_faces="false" font="arial"></fb:like>
                                        </td>
                                        <td>
                                              <!-- email -->
                                                    <a target="_blank" href="mailto:?subject=<?=$this->ad['title'];?>&body=http://segundamanita.com/<?=$this->lang;?>/ad/show/id/<?=$this->ad['id'].'/'.$this->escape($this->ad['title']);?>">
                                                    <img alt="<?=$this->translate('Send by email');?>" src="/images/icons/ico_send_email.png" border = "0"/></a>
                                        </td>
                                        <td>
                                              <!-- Twitter -->
                                              <a href="https://twitter.com/share" class="twitter-share-button" 
                                                  data-url="<?=$this->canonicalUrl ?>"
                                                  data-counturl="<?=$this->canonicalUrl ?>"
                                                  data-via="Segundamanita_"
                                                  data-text="<?= $this->page_title ?>"
                                                  data-count="horizontal"
                                                  data-lang="es">Tweet</a>
                                        </td>
                                      </tr>
                                </table>
            </div>
                    <div class="clearer"></div>    
          <div class="advertising">
              <!-- BEGIN PARTNER PROGRAM - DO NOT CHANGE THE PARAMETERS OF THE HYPERLINK -->
<script language="javascript" type="text/javascript" src="http://program.epartner.es/view.asp?ref=570686&site=8346&type=html&hnb=13&js=1"></script>
<noscript><a href="http://web.epartner.es/click.asp?ref=570686&site=8346&type=b1&bnb=1" target="_blank">
<img src="http://program.epartner.es/view.asp?ref=570686&site=8346&b=1" border="0"/></a><br /></noscript>
<!-- END PARTNER PROGRAM -->
          </div>
          <div class="clearer"></div>    
                    <? if ($this->ad['comments_enabled'] ): ?>
                        <? if ($this->comments ): ?>
                                    <div class="ad_comments">
                                        <h5><?=$this->translate ('Comments');?></h5>
                    
                                   <?php foreach ($this->comments as $key => $val): ?>
                                           <div class="ad_comment">
                                              <span class="ad_date"><?=$this->translate('Posted on '). $this->escape($val['date_created']) ?>
                                                <?=$this->translate('by user ') ?>            
                                            <a class="ads_section" href="/<?=$this->lang ?>/profile/<?=$this->escape($val['username']) ?>"><?=$this->escape($val['username']) ?></a>
                                            </span>
                                               <div class="ad_body"><p><?php echo $this->escapeEmail( $this->escape($val['body']) ) ?></div>
                                        </div>
                                  <?php endforeach; ?>
                                </div>
                            <?php endif;?>

                    <?php if($this->ad['status'] != 'delivered' ): ?>
                            <div class="comment_form"><?=$this->createcomment ?></div>
                   <?php endif; ?>
                    <?php endif;?>
                </div>
            </div>
        </div>

        <div class="span-6 last">
            
            <div class="new_ad_icon">
                <a class="new_ad" href="/<?=$this->lang ?>/ad/create">
                <img alt="<?=$this->translate('Create new ad') ?>" src="/images/icons/ico_new_ad.png" class="valign" /><div class="txt_valign"><?=$this->translate('Create new ad'). $this->woeidNameShort ; ?></div></a>
            </div>
                
            <div class="change_location_icon">
                <a class="change_location" href="/<?=$this->lang ?>/location/change">
                <img alt="<?=$this->translate('Change location' ) ?>" src="/images/icons/ico_change_location.png" class="valign" /><div class="txt_valign"><?=$this->translate('Change location'); ?></div></a>
            </div>
            
            <?php if ($this->ad['status'] != 'delivered'): ?>
                <div class="section_message">
            <h2><?php echo $this->translate('Interested?');?></h2>
                    <div class="messageform"><div class="content_section_message"><div class="private_message_link"><?=$this->messageform ?></div></div></div>
                </div>
             <?php endif;?>
        <div class="clearer"></div>    
    <div class="advertising">
                <!-- BEGIN PARTNER PROGRAM - DO NOT CHANGE THE PARAMETERS OF THE HYPERLINK -->
                <script language="javascript" type="text/javascript" src="http://program.epartner.es/view.asp?ref=570686&site=8346&type=html&hnb=6&js=1"></script>
                <noscript><a href="http://web.epartner.es/click.asp?ref=570686&site=8346&type=b1&bnb=1" target="_blank">
                <img src="http://program.epartner.es/view.asp?ref=570686&site=8346&b=1" border="0"/></a><br /></noscript>
                <!-- END PARTNER PROGRAM -->
        </div>
    </div>

</div> <!-- /main -->
